package entities;

/*
    父类包含成员变量：血量，x，y，图片，图片宽，图片高
 */

import index.StartGame;
import tools.Award;

import java.util.Random;

public class BigEnemy extends FlyingObject implements Award {

    public BigEnemy() {
        //初始位置(y值固定，x值随机)
        super(StartGame.BIG_ENEMY_HP,  //大敌机血量
                new Random().nextInt(StartGame.INTERFACE_WIDTH - StartGame.bigEnemy.getWidth()),  //大敌机初始位置,范围是屏幕从最左侧，到图片右侧贴边结束
                0-StartGame.bigEnemy.getHeight(),  //初始在屏幕外
                StartGame.bigEnemy, //大敌机初始图片
                StartGame.BIG_ENEMY_SCORE);  //大敌机初始分数
        setP_height(getAppearance().getWidth());
        setP_height(getAppearance().getHeight());
    }

    @Override
    public void move() {
        //直线向下
        this.setY(this.getY() + StartGame.BIG_ENEMY_SPEED);
    }

    @Override
    public void giveAward(HeroPlane hero) {
        //给奖励,大敌机给基础奖励或5倍奖励
        int flag = new Random().nextInt(10);
        if (flag < 10 - StartGame.BIG_ENEMY_AWARD_ODDS){
            hero.setScore(hero.getScore() + StartGame.BIG_ENEMY_SCORE);
        }else {
            hero.setScore(hero.getScore() + StartGame.BIG_ENEMY_SCORE * StartGame.BIG_ENEMY_MULTIPLY);
        }
    }
}
